<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区域 -->
    <el-card>
      <!-- 搜索区域 -->
      <el-row :gutter="20">
        <el-col :span="7">
          <!-- v-model="goodsInfo.query" @clear="getGoodsList"    @click="getGoodsList" -->
          <el-input placeholder="请输入搜索内容"  clearable>
            <el-button slot="append" icon="el-icon-search" ></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!-- 订单数据区域 -->
      <el-table :data="orderlist" border stripe>
        <el-table-column type="index" label="id"></el-table-column>
        <el-table-column prop="order_number" label="订单编号"></el-table-column>
        <el-table-column prop="order_price" label="订单价格(元)"></el-table-column>
        <el-table-column prop="pay_status" label="订单状态">
          <el-tag type="success" v-if="orderlist.pay_status === '1' " >已支付</el-tag>
          <el-tag type="danger" v-else>未支付</el-tag>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column prop="create_time" label="下单时间"></el-table-column>
        <el-table-column label="操作" width="220px">
          <!-- 作用域插槽 -->
          <template slot-scope="scope">
            <!-- 编辑按钮 -->
            <el-button type="primary" icon="el-icon-edit" size="mini" @click="showUpdate"></el-button>
            <!-- 物流按钮 -->
            <el-button type="success" icon="el-icon-location" size="mini" @click="showWLInfo(scope.row.user_id)"></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页导航区域 -->、
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryinfo.pagenum"
        :page-sizes="[2, 5, 10]"
        :page-size="queryinfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalNum">
      </el-pagination>
    </el-card>
    <!-- 修改地址对话框区域 -->
    <el-dialog title="修改地址" :visible.sync="updateDialogVisible" width="40%">
      <v-distpicker></v-distpicker>
      <span slot="footer" class="dialog-footer">
        <el-button @click="updateDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="updateDialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 查看物流对话框区域 -->
    <el-dialog title="物流信息" :visible.sync="wlDialogVisible" width="40%">
      
      
    </el-dialog>
  </div>
</template>

<script>
import VDistpicker from 'v-distpicker'
export default {
  components: { VDistpicker },
  data(){
    return{
      // 订单列表
      orderlist:[],
      // 查询参数
      queryinfo:{
        query:'',
        pagenum: 1,
        pagesize: 5
      },
      // 商品总条数
      totalNum:0,
      // 展示修改地址弹出框
      updateDialogVisible:false,
      // 展示查看物流信息弹出框
      wlDialogVisible:false
    }
  },
  created(){
    this.getOrdersList();
  },
  methods:{
    // 获取订单列表 方法
    async getOrdersList(){
      const { data: res } = await this.$http.get("orders", { params: this.queryinfo});
      console.log(res);
      if(res.meta.status !== 200) return this.$message.error("获取订单列表失败");
        this.orderlist = res.data.goods;
        this.totalNum = res.data.total;
        console.log(this.orderlist);
    },
    // 监听每页显示的数量改变
    handleSizeChange(nweSize){
      this.queryinfo.pagesize = nweSize;
      this.getOrdersList();
    },
    // 监听页码值的改变
    handleCurrentChange(newPage){
      this.queryinfo.pagenum = newPage;
      this.getOrdersList();
    },
    // 展示修改地址弹出框
    showUpdate(){
      this.updateDialogVisible = true;
    },
    // 展示物流信息
    async showWLInfo(id){
      // const { data: res } = await this.$http.get("/kuaidi/" + id, '1106975712662');
      // console.log(res);
      // if(res.meta.status !== 200) return this.$message.error("获取物流信息失败");
      //   console.log('ok');
        this.wlDialogVisible = true;
    }
  },
  
}
</script>

<style>

</style>